#pragma once
#include "dbs.h"
#include "def.h"

class DbsSqlite3 : public Dbs
{

public:
    DbsSqlite3();
    virtual ~DbsSqlite3();
public:
    virtual bool Open() override;
    virtual void Close() override;
protected:
    virtual bool Inquiry(const char* sql) override;
    virtual bool Exec(const char* sql) override;
public:
    // file table name 
    virtual void SetTableName(const std::string& name) override;
    // file table
    virtual bool MakeTable()override;
    virtual int GetCount(const char* sql) override;
    // file info
    virtual int SelectFileInfo(const std::string& relative, StFileInfo& info)override;
    virtual bool InsertFileInfo(const StFileInfo* info, int size) override;
    virtual bool UpdateFileInfo(const StFileInfo* info, int size) override;
    virtual bool SelectFileLatestPacket(int64_t& packet) override;

    // version info 
    virtual int SelectVersionInfo(const std::string& app, StVersionInfo& info)override;
    virtual bool InsertVersionInfo(const StVersionInfo& info) override;
    virtual bool UpdateVersionInfo(const StVersionInfo& info) override;


private:
    int64_t GetColumnInt64(int col);
      
private:
    struct DbsSqlite3Impl;
    DbsSqlite3Impl* m_impl{ nullptr };

};

